package team.seekers.hula.course.courseUser.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.common.entity.PageResult;
import team.seekers.hula.course.courseUser.entity.dto.CourseUserBindDTO;
import team.seekers.hula.auth.service.MindUtils;
import team.seekers.hula.course.courseUser.entity.dto.CourseEvaluationReqListDTO;
import team.seekers.hula.course.courseUser.entity.vo.CourseEvaluationListVO;
import team.seekers.hula.course.courseUser.service.CourseUserService;


@Controller
@ApiResponseBody
@RequestMapping("/course/user")
@Slf4j
public class CourseUserController {

    @Autowired
    private CourseUserService courseUserService;

    /**
     * 知桨用户绑定
     */
    @PostMapping("/join")
    public void join(@RequestBody CourseUserBindDTO courseUserBindDTO){

        // 检查是否已经缴费，这里应该是从支付完成处触发，如果是免费知桨则从这里触发

        courseUserBindDTO.setUserId(MindUtils.getUserId());
        courseUserService.bind(courseUserBindDTO);
    }

//    @GetMapping("/page")
//    public PageResult<CourseUserListVO> page(CourseUserReqListDTO reqDTO) {
//        reqDTO.setUserId(MindUtils.getUserId());
//        return courseUserService.page(reqDTO);
//    }

    @GetMapping("/fixedOrCancel")
    public void fixedOrCancel(@RequestParam String courseId) {
        courseUserService.fixedOrCancel(courseId,MindUtils.getUserId());
    }

    @GetMapping("/collectOrCancel")
    public void collectOrCancel(@RequestParam String courseId) {
        courseUserService.collectOrCancel(courseId,MindUtils.getUserId());
    }

    @GetMapping("/evaluation/page")
    public PageResult<CourseEvaluationListVO> listEvaluation(CourseEvaluationReqListDTO listDTO) {
        return courseUserService.pageEvaluation(listDTO);
    }


}
